<template>
  <div>
    <el-button
      class="add"
      @click="add"
      icon="el-icon-circle-plus-outline"
      type="success"
      >添加</el-button
    >
    <list ref="list" @edit="edit"></list>
    <info ref="info" :info="info" @update="update"></info>
  </div>
</template>

<script>
import Info from "./Info.vue";
import List from "./List.vue";
export default {
  data() {
    return {
      info: {
        // 弹窗是否展示
        isShow: false,
      },
    };
  },
  components: { List, Info },
  methods: {
    // 新增
    add() {
      // 显示弹窗
      this.info.isShow = true;
      // 弹窗类型
      this.info.type = "add";
      this.$refs.info.setVal({
        first_cateid: 0,
        second_cateid: 0,
        goodsname: "",
        price: 1,
        market_price: 1,
        img: "",
        description: "",
        sepcsid: 1,
        sepcsattr: [],
        isnew: 1,
        ishot: 1,
        // 1正常2禁用
        status: 1,
      });
    },
    // 编辑
    edit(data) {
      // 显示弹窗
      this.info.isShow = true;
      // 弹窗类型
      this.info.type = "edit";
      this.$refs.info.setVal(data);
    },
    // 更新list组件中的内容
    update() {
      this.$refs.list.getTabelList();
    },
  },
};
</script>

<style>
.add {
  margin-bottom: 20px;
}
</style>